<extend name="Public/base" />
<block name="content">
    <div class="row">
        <div class="col-md-12">
<!-- Horizontal Form -->
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">{$title}</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal" method="post" action="__SELF__" id="ajaxForm01">
                <div class="box-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">菜单名 (required)</label>
                        <div class="col-sm-10">
                            <input class=" form-control"  name="title"  type="text"  value="{$info.title}" placeholder="菜单名"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">上级菜单 (required)</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="pid"  placeholder="上级菜单">
                                <option value="0">一级菜单</option>
                                <volist name="menuList" id="vo">
                                    <option value="{$vo.id}" <if condition="$vo['id'] eq $info['pid']">selected </if> >{$vo.title}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">URL (required)</label>
                        <div class="col-sm-10">
                            <input class=" form-control"  name="url"  type="text"  value="{$info.url}" placeholder="URL"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">序列号(倒序排序)</label>
                        <div class="col-sm-10">
                            <input class=" form-control"  name="sort"  type="number"  value="{$info['sort']?:$maxSort}" placeholder="序列号"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">描述</label>
                        <div class="col-sm-10">
                            <input class=" form-control"  name="description"  type="text"  value="{$info.description}" placeholder="描述"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">组</label>
                        <div class="col-sm-10">
                            <input class=" form-control"  name="description"  type="text"  value="{$info.description}" placeholder="组"/>
                        </div>
                    </div>

                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <div class="row">
                       <div class="col-md-offset-4">
                           <notempty name="info.id">
                               <input type="hidden" name="id" value="{$info.id}"/>
                           </notempty>
                           <button type="reset" class="btn btn-default">取消</button>&nbsp;&nbsp;&nbsp;
                           <input type="submit" class="btn btn-info" value="提交" >
                        </div>
                    </div>

                </div>
                <!-- /.box-footer -->
            </form>
        </div>
<!-- /.box -->
         </div>
    </div>

</block>
 <block name="js">
     <script>
         $( document ).ready( function () {
             $("#ajaxForm01").validate({
                 rules: {
                     title: "required",
                     url: "required",
                     pid: "required"
                 },
                 messages: {
                     title: "菜单名必填",
                     url: "url必填",
                     pid: "上级菜单必填"
                 },
                 errorElement: "em",
                 errorPlacement: function (error, element) {
                     // Add the `help-block` class to the error element
                     error.addClass("help-block");

                     if (element.prop("type") === "checkbox") {
                         error.insertAfter(element.parent("label"));
                     } else {
                         error.insertAfter(element);
                     }
                 },
                 highlight: function (element, errorClass, validClass) {
                     $(element).parents("div").addClass("has-error").removeClass("has-success");
                 },
                 unhighlight: function (element, errorClass, validClass) {
                     $(element).parents("div").addClass("has-success").removeClass("has-error");
                 }
             });
         })
     </script>
 </block>